package com.jing.weibo.service.info;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.info.InfoMapper;
import com.jing.weibo.pojo.info.Info;

/**
 * 信息的Service
 * @author jing.yue
 * @version 2012/09/25 1.0.0
 */
@Component
public class InfoService {

	@Autowired
	private InfoMapper infoMapper;

	/**
	 * 保存信息
	 * @param info
	 * @throws Exception
	 */
	public void saveInfo(Info info) throws Exception {
		infoMapper.saveInfo(info);
	}

	/**
	 * 分页获取信息列表
	 * @param info
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findInfo(Info info) throws Exception {
		List<Info> infos = infoMapper.findInfo(info);
		Integer countSize = infoMapper.findInfoCount(info);
		PageCls pageCls = PageCls.setPageCls(info.getPage(), info.getSize(), null, null, countSize, infos.size(), infos);
		return pageCls.getPageInfo();
	}

	/**
	 * 根据ID获取对象
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Info findByIdInfo(Integer id) throws Exception {
		return infoMapper.findByIdInfo(id);
	}

	/**
	 * 根据ID修改信息转发数
	 * @param info
	 * @throws Exception
	 */
	public void updateInfoTranspond(Info info) throws Exception {
		infoMapper.updateInfoTranspond(info);
	}

	/**
	 * 获取所有信息
	 * @return
	 * @throws Exception
	 */
	public List<Info> findAllInfo() throws Exception {
		return infoMapper.findAllInfo();
	}
}
